import Request from './request.js';

const API = {
	effectiveCouponList: '/app/bus/coupon/effectiveList', // 可领取优惠券列表接口
	receivedCouponList: '/app/bus/coupon/receivedList', // 已领取优惠券列表接口
	receiveCoupon: '/app/bus/coupon/receive', // 领取优惠券接口
	validCouponList: '/app/bus/coupon/validList', // 下单时获取可用优惠券列表接口
	exchangeCoupon: '/app/bus/coupon/exchange', // 券码兑换接口
	defaultCoupon: '/app/bus/coupon/defaultCoupon' // 默认优惠券计算接口
};

// 查询可领取优惠券列表
export const getEffectiveCouponList = (queryParams) => {
	return Request.get(API.effectiveCouponList, {
		params: queryParams
	});
};

// 我的页面中卡券列表
export const getReceivedCouponList = (queryParams) => {
	return Request.get(API.receivedCouponList, {
		params: queryParams
	});
};

// 领取优惠券
export const receiveCoupon = (couponId) => {
	return Request.get(API.receiveCoupon, {
		params: {
			couponId: couponId
		}
	});
};

// 下单时获取可用优惠券列表
export const getValidCouponList = (queryParams) => {
	return Request.get(API.validCouponList, {
		params: queryParams
	});
};

// 券码兑换
export const exchangeCoupon = (relateCode) => {
	return Request.get(API.exchangeCoupon, {
		params: {
			relateCode: relateCode
		}
	});
	// 或者如果接口是POST请求，可以这样写：
	// return Request.post(API.exchangeCoupon, {
	//     relateCode: relateCode
	// });
};

// 计算默认优惠券
export const calculateDefaultCoupon = (queryParams) => {
	return Request.get(API.defaultCoupon, {
		params: queryParams
	});
};